<template>
  <section class="searchForm">
    <el-form
      :model="searchValidateForm"
      ref="searchValidateForm"
      label-width="100px"
      :inline="true"
    >
      <el-form-item label="用户账号" prop="account">
        <el-input
          type="account"
          v-model="searchValidateForm.account"
          autocomplete="off"
        ></el-input>
      </el-form-item>

      <el-form-item label="碎片名称" prop="name">
        <el-input
          type="name"
          v-model="searchValidateForm.name"
          autocomplete="off"
        ></el-input>
      </el-form-item>

      <el-form-item label="状态" prop="status">
        <el-select v-model="searchValidateForm.status" placeholder="请选择">
          <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-button
          type="primary"
          @click="submitForm('searchValidateForm')"
          class="search-btn"
          >查询</el-button
        >
        <el-button @click="resetForm('searchValidateForm')">重置</el-button>
      </el-form-item>
    </el-form>
  </section>
</template>

<script>
export default {
  data() {
    return {
      searchValidateForm: {
        name: "",
        account: "",
        status: "",
      },
      options: [
        {
          value: "选项1",
          label: "黄金糕",
        },
        {
          value: "选项2",
          label: "双皮奶",
        },
        {
          value: "选项3",
          label: "蚵仔煎",
        },
        {
          value: "选项4",
          label: "龙须面",
        },
        {
          value: "选项5",
          label: "北京烤鸭",
        },
      ],
    };
  },
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate((valid, form) => {
        if (valid) {
          alert("submit!");
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
  },
};
</script>
<style lang="scss" scoped>
.searchForm {
  width: 100%;
  background: #fff;
  border-radius: 4px;
  box-sizing: border-box;
  min-height: 60px;
  margin-bottom: 20px;
  .el-form-item {
    margin-top: 10px;
    margin-bottom: 10px;
    .el-input {
      width: 240px;
    }
  }
  .search-btn {
    margin-left: 60px;
  }
  .btns {
    padding-bottom: 10px;
  }
}
</style>
